package com.uzai.common.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @Auther: xiaoyuexl
 * @Date: 2021/8/16 11:34
 * @Description:
 */
public enum PlatformTypeEnum {
    PT_TAOBAO(0, "tb","淘宝"),
    PT_JD(1, "jd","京东"),
    PT_PDD(2, "pdd","拼多多"),
    PT_VPH(3, "vph","唯品会"),
    PT_LOCAL_LIVE(4, "local_live","本地生活"),
    PT_CHAT(5, "y_chat","悠聊"),
    PT_CMS(6, "cms","CMS"),
    PT_MT_FX(7, "mt_fx","美团分销"),
    PT_MT_LM(8, "mt_lm","美团联盟"),
    PT_ELM(9, "elm","饿了么"),
    PT_TAOBAO_REFUND(10, "tb_refund","淘宝维权"),
    PT_DY(11, "dy","抖音"),
    PT_KS(12, "ks","快手");

    public static final int PT_TAOBAO_VALUE = 0;
    public static final int PT_JD_VALUE = 1;
    public static final int PT_PDD_VALUE = 2;
    public static final int PT_VPH_VALUE = 3;
    public static final int PT_LOCAL_LIVE_VALUE = 4;
    public static final int PT_CHAT_VALUE = 5;
    public static final int PT_CMS_VALUE = 6;
    public static final int PT_MT_FX_VALUE = 7;
    public static final int PT_MT_LM_VALUE = 8;
    public static final int PT_ELM_VALUE = 9;
    public static final int PT_TAOBAO_REFUND_VALUE = 10;
    public static final int PT_DY_VALUE = 11;
    public static final int PT_KS_VALUE = 12;


    public static final String TB_KEY = "tb";
    public static final String JD_KEY = "jd";
    public static final String PDD_KEY = "pdd";
    public static final String VPH_KEY = "vph";
    public static final String DY_KEY = "dy";
    public static final String MT_KEY = "mt";
    public static final String ELM_KEY = "elm";
    public static final String KS_KEY = "ks";

    private Integer id;
    private String key;
    private String desc;
    PlatformTypeEnum(Integer id, String key, String desc) {
        this.id = id;
        this.key = key;
        this.desc = desc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static PlatformTypeEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (PlatformTypeEnum type: PlatformTypeEnum.values()) {
            if (type.getId().intValue() == id) {
                return type;
            }
        }
        return null;
    }

    public static PlatformTypeEnum getByKey(String key) {
        if (StringUtils.isBlank(key)) {
            return null;
        }
        for (PlatformTypeEnum type: PlatformTypeEnum.values()) {
            if (type.getKey().equals(key)) {
                return type;
            }
        }
        return null;
    }
}
